﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lesson3_练习题
{
    internal class Program
    {
        //基于成员变量练习题
        //为人类定义说话，走路，吃饭等方法
        class Person
        {
            public int age;
            public string name;   
            public string address;

            

            public void Speak(string str)
            {
                Console.WriteLine("{0}说{1}",name,str);
            }

            public void Walk()
            {
                Console.WriteLine("{0}开始走路了",name);
            }
           public void Eat(Fruit f)
            {
                Console.WriteLine("{0}才刚开始吃{1}",name,f.name);
            }
        }
        class Fruit
        {
            public string name;   //火龙果的名字
            public string kaluli;  //若是想将水果的热量写进去，就可以实例化卡路里进行编写
        }
        static void Main(string[] args)
        {
            #region 练习题一
            //Person p = new Person();
            //p.age = 18;
            //p.name = "张三";
            //p.Speak("刘翔是超人");
            //p.name = "王五";    //重新赋值的操作
            //p.Walk();
            #endregion
            #region 将人和水果练习起来的方法，例如张三才刚开始吃火龙果
            Person p = new Person();
            p.name = "张三";

            Fruit f = new Fruit();
            f.name = "火龙果";
            p.Eat(f);
            #endregion
        }
    }
}
